#include <cstdint>
#include <iostream>

using ll = int64_t;

ll T,n,m,k,kp;

int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cin>>T;
    while(T--){
        std::cin>>n>>m>>k;
        bool isn2n=false;
        ll n2n=0;
        for(ll i=1;i<=m;i++){
            std::cin>>kp;
            nxt:;
            if(isn2n && kp!=2*n-1){
                if((n2n&1)==0){
                    for(ll j=1;j<=n2n;j++){
                        std::cout<<1<<" "<<n<<"\n";
                        goto nxt;
                    }
                }else{
                    if((kp&1)==0){
                        for(ll j=1;j<=n2n;j++){
                            std::cout<<1<<" "<<((kp+1)>>2)<<"\n";
                        }
                        
                    }
                }
                isn2n=false;
                n2n=0;
            }else if(kp==2*n-1){
                n2n++;
                isn2n=true;
            }
        }
    }
}